package simulacionproyecto;


public class VariableGenerator {
    private double _varUniA;
    private double _varUniB;
    public double _varPromedio;
    public double _varMedia;
    public double _varDesviacion;
    
    
    public VariableGenerator(double valorA, double valorB, String nombreGen) {
        if(nombreGen.equals("normal")){
            this._varMedia = valorA;
            this._varDesviacion = valorB;
        }else{
            this._varUniA = valorA;
            this._varUniB = valorB;
        }
        
    }
    
    public VariableGenerator(double promedio) {
        this._varPromedio = promedio;
    }
    
    
    public double calcularExponencial(double randomNumber){
        
        double valor = -1*this._varPromedio*(Math.log(1-randomNumber));
        return valor;
    }
    
    public double calcularNormal(double randomNumber){
        double valor = this._varMedia + this._varDesviacion*(randomNumber - 6);
        return valor;
    }
    
    public double calcularUniforme(double randomNumber){
        double valor = this._varUniA + randomNumber*(this._varUniB-this._varUniA);
        return valor;
    }
    
    public double calcularDiscreta(double randomNumber){
        // no sé como sería la discreta
        double valor = 0;
        return valor;
    }
    
    public double calculate(String generatorName, double randomNumber){
        double valor = 0;
        if(generatorName.equals("exponencial")){
            valor = this.calcularExponencial(randomNumber);
        }else if(generatorName.equals("uniforme")){
            valor = this.calcularUniforme(randomNumber);
        }else if(generatorName.equals("normal")){
            valor = this.calcularNormal(randomNumber);
        }else if(generatorName.equals("discreta")){
            valor = this.calcularDiscreta(randomNumber);
        }
        return valor;
    }
    
    
}
